package com.yinhai.message.client.tool;

import java.util.List;

import com.yinhai.message.api.bean.TMMessage;
import com.yinhai.message.api.bean.TMUser;
import com.yinhai.message.api.exception.TMException;

public class TMSendValidate {
	
	public static boolean validateInfo(TMUser sendUser,List<TMUser> receiveUserList,TMMessage tmMessage) throws TMException{
		if(sendUser==null || sendUser.getAppId()==null || sendUser.getUserId()==null){
			throw new TMException("发送人员的系统id 或 人员id 为空");
		}
		if(receiveUserList==null || receiveUserList.size()==0){
			throw new TMException("接收人员列表为空");
		}
		for(TMUser receiveUser: receiveUserList){
			if(receiveUser==null || receiveUser.getAppId()==null || receiveUser.getUserId()==null){
				throw new TMException("接收人员列表中的系统id 或 人员id 为空--index:"+receiveUserList.indexOf(receiveUser));
			}
		}
		if(tmMessage==null || tmMessage.getTitle()==null || tmMessage.getContent()==null){
			throw new TMException("消息的title 或 content 为空");
		}
		return true;
	}
}
